<%@ page language="java" contentType="text/html; charset=UTF-8"
         pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en" class="no-js">

<head>

    <meta charset="utf-8">
    <title>注册页面</title>
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="description" content="">
    <meta name="author" content="">

    <!-- CSS -->
    <link rel='stylesheet' href='http://fonts.googleapis.com/css?family=PT+Sans:400,700'>
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/reset.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/supersized.css">
    <link rel="stylesheet" href="${pageContext.request.contextPath}/assets/css/style.css">


    <!-- HTML5 shim, for IE6-8 support of HTML5 elements -->
    <!--[if lt IE 9]>
    <script src="http://html5shim.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->

    <script type="text/javascript">
        function regist(){
            var phone=document.getElementById("phone").value;
            var code=document.getElementById("code").value;
            var pwd = document.getElementById("regist_password").value;
            //alert(thisPwd);
            //bodyRSA();
            //var result = encryptedString(key, encodeURIComponent(thisPwd));
            //alert(encodeURIComponent(thisPwd)+"\r\n"+result);
            $.ajax({
                url:"${pageContext.request.contextPath}/home/regist",
                type:"post",
                data:{"user_phone":phone,
                "checkCode":code,
                "regist_password":pwd},
                success:function (data) {
                    if(data=="success"){
                        alert("注册成功，请登录");
                        window.location.href='${pageContext.request.contextPath}/home/doLogin';
                    }else{
                        alert("验证失败");
                    }
                }
            });
        }
        var key ;
        function bodyRSA(){
            setMaxDigits(130);
            key = new RSAKeyPair("10001","","a1be9319d13fae8a0bb6ea5823df10ea3a2f2e085e8f904fa199aefecfaa61fac16ef7ebedb56943f7874b0ad2511d3ca22f6cec5bd827c11200c47c2a7323eb");
        }

        function sendcode(){
           var phonenumber= document.getElementById("phone").value;
           $.ajax({
               url:"${pageContext.request.contextPath}/home/getCheckCode",
               type:"post",
               data:{"user_phone":phonenumber},
               success:function (data) {
                   alert('发送');
               }
           });
        }
    </script>

</head>

<body>

<div class="page-container">
    <h1>注册</h1>
    <form id="formid" action="${pageContext.request.contextPath}/home/regist" method="post">
        <input type="text" id="phone" name="user_phone" class="username" placeholder="手机">
        <input type="text" id="code" name="checkCode" class="username" placeholder="验证码">
        <input type="password" id="regist_password" name="regist_password" class="password" placeholder="密码">
        <button type="button" onclick="regist()" >注册</button>
        <button type="button" onclick="sendcode()" >获取验证码</button>
        <div class="error"><span>+</span></div>
    </form>

</div>

<!-- Javascript -->
<script src="${pageContext.request.contextPath}/assets/js/jquery-1.8.2.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/supersized.3.2.7.min.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/supersized-init.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/scripts.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/RSA.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/BigInt.js"></script>
<script src="${pageContext.request.contextPath}/assets/js/Barrett.js"></script>
</body>

</html>

